<?php
include_once '../inc/config.inc.php';
include_once '../inc/mysql.inc.php';
include_once 'inc/tool.inc.php';
$link=connect();
include_once 'inc/is_manage_login.inc.php';//验证管理员是否登录

if(isset($_POST['submit'])){
	//转义入库
	//$_POST=escape($link,$_POST);

	$query="insert into propage2(title,content,author,url_link,propic,note,time) values('{$_POST['title']}','{$_POST['content']}','{$_POST['author']}','{$_POST['url_link']}','{$_POST['propic']}','{$_POST['note']}',now())";
	execute($link,$query);
	if(mysqli_affected_rows($link)==1){
		skip('scenery.php','ok','恭喜你，添加成功！');
	}else{
		skip('scenery_add.php','error','对不起，添加失败，请重试！');
	}
}

if(!isset($_GET['id']) || !is_numeric($_GET['id'])){
	skip('scenery_add.php','error','id参数错误！');
}

$query="select * from propage2 where id={$_GET['id']}";
$result=execute($link,$query);
$data=mysqli_fetch_assoc($result);

$template['title']='风景名胜添加页';
$template['css']=array('style/public.css');
?>
<?php include 'inc/header.inc.php'?>
<div id="main">
	<div class="title" style="margin-bottom:20px;">添加景点</div>
	<form method="post">
		<table class="au">
			<tr>
				<td>标题</td>
				<td><input name="title" required="required" placeholder="请输入标题" maxlength="25" type="text" /></td>
				<td>
					名称不得为空，不得超过25个字符
				</td>
			</tr>
			<tr>
				<td>作者</td>
				<td><input name="author" required="required" placeholder="请输入作者" maxlength="10" type="text" /></td>
				<td>
					作者不得为空，不得超过10个字符
				</td>
			</tr>
			<tr>
				<td>缩略图</td>
				<td><textarea name="url_link" required="required" placeholder="请输入缩略图" rows="5" cols="10"><?php echo htmlentities($data['url_link'],ENT_COMPAT,"UTF-8")?></textarea></td>
				<td>
					缩略图不得为空,请输入正确的图片src地址
				</td>
			</tr>
			<tr>
				<td>项目图</td>
				<td><textarea name="propic" required="required" placeholder="请输入项目图" rows="5" cols="10"><?php echo htmlentities($data['propic'],ENT_COMPAT,"UTF-8")?></textarea></td>
				<td>
					请输入正确的图片src地址,根据html模板编辑
				</td>
			</tr>
			<tr>
				<td>简要描述</td>
				<td><textarea name="note" required="required" placeholder="请输入简要描述" rows="5" cols="10"><?php echo htmlentities($data['note'],ENT_COMPAT,"UTF-8")?></textarea></td>
				<td>
					景点简要描述,根据html模板编辑
				</td>
			</tr>
			<tr>
				<td>详细内容</td>
				<td><textarea name="content" required="required" placeholder="请输入详细内容" rows="5" cols="10"><?php echo htmlentities($data['content'],ENT_COMPAT,"UTF-8")?></textarea></td>
				<td>
					景点详情内容,根据html模板编辑
				</td>
			</tr>
		</table>
		<input style="margin-top:20px;cursor:pointer;" class="btn" type="submit" name="submit" value="添加" />
	</form>
</div>
<?php include 'inc/footer.inc.php'; close($link);?>